<template>
  <view>
	  <u-navbar back-text="返回" title="处理列表数据" @leftClick="goToPre()"></u-navbar>
	  <view class="mobile-item-container">
		<Navbar title="出勤管理" bgColor="#fff" :h5Show="false"></Navbar>
		<!-- <Tabs :tabs="tabs" @change="tabChange" style="margin-bottom: 16px;"></Tabs> -->
		<Record v-if="activeKey == 'draft'" :list="dutySubmitList" @click="navigateTo"></Record>
		<!-- <Record v-if="activeKey == 'published'" :list="list" @click="navigateTo"></Record> -->
		<FloatScanButton type="primary" icon="plus" @click="navigateTo"></FloatScanButton>
	  </view>
  </view>
</template>

<script>
import * as BaseApi from '@/api/base/base';
import * as NoticeApi from '@/api/work/notice';
import Navbar from '@/components/navbar/Navbar';
import FloatScanButton from '@/components/button/FloatScanButton';
import Tabs from '@/components/tabs/Tabs';
import Record from './record';

export default {
  components: {
    Navbar,
    FloatScanButton,
    Tabs,
    Record,
  },
  data () {
    return {
      activeKey: 'draft',
      tabs: [{
        name: '草稿',
        key: 'draft',
      }, {
        name: '已发布',
        key: 'published'
      }],
      params: {
        pageNum: 0,
        pageSize: 10
      },
	 dutySubmitList: [],
    }
  },
  created () {
    this.loadData()
  },
  methods: {
    // 加载通知公告数据
    loadData () {
		BaseApi.getWorkSubmitList({pageNum: 1, pageSize: 50}).then(res => {
			console.log("出勤填报查询:", res);
			if (res && res.rows) {
				this.dutySubmitList = res.rows || [];
			}
		});
    },
    // 滚动分页加载数据
    scrolltolower () {
      this.loadData();
    },
    // tabChange (tab) {
    //   this.activeKey = tab.key;
    //   this.params.pageNum = 0;
    //   this.loadData();
    // },
    navigateTo (item) {
      if (item && item.id) {
        uni.navigateTo({ url: '/pages/work/dayreport/dutysubmit?id=' + item.id })
      } else {
        uni.navigateTo({ url: '/pages/work/dayreport/dutysubmit' })
      }
    },
	goToPre() {
		console.log("返回主页");
		uni.reLaunch({ url: '/pages/work/index' });
	},
  }
}
</script>

<style lang="scss" scoped>
.mobile-item-container {
	padding-top: 38px;
}
.list-item {
  padding: 20rpx 0;
  border-bottom: 0.5px solid #ccc;
}
</style>